1 |
|
2 |
|
3 | import colors from 'colors/safe'
|
4 |
|
5 | function error(error)
|
6 | {
|
7 | console.error(colors.red(error))
|
8 | }
|
9 |
|
10 | function warning(warning)
|
11 | {
|
12 | console.log(colors.yellow(warning))
|
13 | }
|
14 |
|
15 | let first_run = true
|
16 | let was_faulty = false
|
17 |
|
18 | export default function notify_stats(stats, json, verbose)
|
19 | {
|
20 |
|
21 | if (json.errors && json.errors.length > 0)
|
22 | {
|
23 | was_faulty = true
|
24 | return json.errors.forEach(error)
|
25 | }
|
26 |
|
27 |
|
28 | if (json.warnings && json.warnings.length > 0)
|
29 | {
|
30 | json.warnings.forEach(warning)
|
31 | }
|
32 |
|
33 |
|
34 |
|
35 | if (!verbose && !first_run && was_faulty)
|
36 | {
|
37 |
|
38 | console.log(colors.green('~ Webpack build status: OK ~'))
|
39 |
|
40 | was_faulty = false
|
41 | }
|
42 |
|
43 | if (verbose || first_run)
|
44 | {
|
45 | console.log(stats.toString
|
46 | ({
|
47 | chunks: false,
|
48 | colors: true
|
49 | }))
|
50 |
|
51 | first_run = false
|
52 | }
|
53 | }
|